package com.sicheng.algorithm.dynamic;

/**
 * @author zsc
 * @version 1.0
 * @date 2022/1/23 21:36
 */
public class 连续子数组的最大和 {
    public static void main(String[] args) {
        int[] nums = {-1, -2, -3, 0, -1, -2, 9};

        int best = Integer.MIN_VALUE;
        int sum = 0;
        for (int num : nums) {

            sum = sum <= 0 ? num : sum + num;
            best = Math.max(sum, best);
        }
        System.out.println(best);

    }
}
